﻿@using CodeCamp.Models.Schedule
@using CodeCamp.Models.Shared
@using CodeCamp.Infrastructure.Extensions
@model ScheduleIndexViewModel
@{
    ViewBag.Title = "";
    string headline;
    if ((@Model != null) && (@Model.EventDisplayName != null))
    {
        ViewBag.Title = @Html.Encode(@Model.EventDisplayName + " | Schedule");
        headline = @Model.EventDisplayName + " Schedule";
    }
    else
    {
        ViewBag.Title = "Code Camp | Schedule";
        headline = "Code Camp Schedule";
    }
}

@if (Model.ScheduleIsPublic)
{
<h2>@headline</h2>
}
else
{
<h2>@headline - NOT YET PUBLIC</h2>
}

<p>
    View the @Html.ActionLink("Agenda", "Agenda", new { eventName = Model.EventShortName }) to see @Model.EventDisplayName at a glance.
    View the @Html.ActionLink("Session Schedule by Room", "Rooms", new { eventName = Model.EventShortName }) to see the schedule for all rooms.
</p>
<p>
    Details are subject to change. But you already knew that.
</p>
<h3>@Model.EventStartDate.ToLongDateString()</h3>

@if (Model.ScheduleIsPublic || Model.ScheduleInsider || Model.ScheduleVisibleForPresenter)
{
    <table class="schedule">
      <tr class="horizontalLayout">
        <td class="col1"></td>
        <td class="col2"></td>
        <td class="col3"></td>
        <td class="col4"></td>
        <td class="col5"></td>
        <td class="col6"></td>
      </tr>
    @foreach (var timeslot in Model.Timeslots)
    {
      <tr class="timeslotRow">
        <td class="startTime" colspan="2">@timeslot.StartTime.ToShortTimeString()&nbsp;&ndash;</td>
        <td class="endTime">@timeslot.EndTime.ToShortTimeString()</td>
        <td class="name" colspan="3">@timeslot.Name</td>
      </tr>
      foreach (var session in timeslot.Sessions.OrderBy(s => s.Building).ThenBy(s => s.Floor).ThenBy(s => s.Room))
      {
          <tr class="sessionRow">
              <td>&nbsp;</td>
              <td class="title" colspan="3" >@Html.ActionLink(session.Title, "Details", "Sessions", new { eventName = Model.EventShortName, id = session.SessionId}, null)</td>
              <td class="presenters">
            @{
                var first = true;
                foreach(var presenter in session.Presenters)
                {
                    if (!first) { <text>, </text> }
                    else { first = false; }
                    @Html.ActionLink(presenter.Name, "Details", "Presenters", new { eventName = Model.EventShortName, id = presenter.PresenterId}, null)
                }
            }
              </td>
              <td class="location">@Html.ActionLink(session.RoomInfo, "Room", new { eventName = Model.EventShortName, id = session.RoomId }, null)</td>
          </tr>
      }  
    }
    </table>
}

@section sidebar {
    @Html.Partial("SidebarCommonPartial")
}
